<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 * Smarty summarize modifier plugin
 * 
 * Type:     modifier<br>
 * Name:     sumamrize<br>
 * Purpose:  summarize a string down to $limit words<br>
 *  @link http://smarty.incutio.com/?page=Smarty
 *          summarize (Smarty Plugins Wiki)
 * Input:<br>
 *         - string: input string of words
 *         - limit: number of words to return
 * @param string
 * @param int
 * @return string
 */
function smarty_modifier_summarize($string, $limit=20)
{
	$limit = limit_Ads_Words_Payed;

    $words = 0;
	$return = "";

	if($limit<1) return $return;

	$word = strtok($string, " \n\t");
	$return .= $word;

    while($word && (++$words < $limit)) {
		$word = strtok(" \n\t");
		$return .= " $word";
    }
	return $return." ...";
}

/* vim: set expandtab: */

?>
